import re
from sys import stdin

prev_indent = -2
output = ""
for ln in stdin.readlines():
    indent = len(re.match(r"\s*", ln)[0])
    if indent > prev_indent:
        output += "\n"
        prev_indent = indent
    else:
        while indent < prev_indent:
            prev_indent -= 2
            output += "]\n" + " " * prev_indent
        output += "]\n"
    output += " " * indent + "[" + ln.strip()
while 0 < prev_indent:
    prev_indent -= 2
    output += "]\n" + " " * prev_indent
output += "]"

subs = [
    (r"(?:\n\s*)?\[\|(.*?)\](?:\n\s*)?", r"\1 "),
    (r"\] ([.,?!])", r"]\1"),
    (r"(?<=\S)  +", " "),
    (r"\[(\w+)(\.[-\w]+)\((.+?)\)", r"[<\1> \2; \3;"),
    (r"\[(\w+)\((.+?)\)", r"[<\1> \2;"),
    (r"\[(\w+)(\.[-\w]+)", r"[<\1> \2;"),
    (r"\[(\w+)", r"[<\1>"),
    (
        r"\[<extends> ([./]*)templates/main.jade[\s\S]*?\n\]",
        r"[inject \1templates/main.xd]",
    ),
    (r"\[<block> content", ""),
    (r"\[<block> title", "[set-title"),
    (r"\]$", ""),
    (r'\[<a> href="(.+?)"; (.+?)\]', r"[link \2; \1]"),
    (r"<p>", "p"),
    (r"<ul>", "list"),
    (r"<h1>", "show-title"),
    (r"\[<li> ([^\[\]]*)]", r"\1;"),
    (r"\[<h[2-6]> ([^\[\]]*)]", "[section \\1;\n]"),
]
for a, b in subs:
    output = re.sub(a, b, output)

print(output, end="")
